﻿using System;
using System.Diagnostics;
using Autodesk.Revit.Attributes;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using YJKRevitBase.WinForm;
using YJKWndrStatisticsExcel.FastStatisticTable.Utility;
using YJKRevitView;

namespace YJKWndrStatisticsExcel.DoorAndWindowTable
{
	[Transaction(TransactionMode.Manual)]
	internal class CmdDoorWndStatisticTable : IExternalCommand
	{
		public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
		{
			CmdViewType types = CmdViewType.FloorPlan;
			if (SwitchView.SetUsableView(types, commandData) != Autodesk.Revit.UI.Result.Succeeded)
			{
				return Autodesk.Revit.UI.Result.Failed;
			}
			WindowHandle windowHandle = null;
			if (windowHandle == null)
			{
				windowHandle = new WindowHandle(Process.GetCurrentProcess().MainWindowHandle);
			}


            // 需要addin 自动加载，thisApp 才不会是 null
            FastMaterialDlgApp.thisApp.ShowForm(commandData, windowHandle, true);

			return Autodesk.Revit.UI.Result.Succeeded;
		}
	}
}
